<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
		</script>

		<!-- .breadcrumb -->
	</div>
	<!-- Main content -->
	<div class="page-content">
    	<div class="row">
    	    <div class="page-header">
    			<h1>编辑订单</h1>
    		</div>
    		<div class="col-md-12 col-sm-12 col-xs-12 form">
             
			</div>
            <div class="col-xs-12 margin_t margin_b">
				<div class="table-responsive  tab">
					<form action="" id='add'>
						<div class="form-group col-xs-6">
                            <label>总金额</label>
                            <input name="real_price" type="text" class="form-control"  value="<?php echo $error['real_price']?>" check-type="required">
                        </div>
                        <div class="form-group col-xs-6 ">
                            <label>订单金额</label>
                            <input name="order_price" type="text" class="form-control" value="<?php echo $order['order_price']?>" check-type="required">
                        </div>
                        <div class="form-group col-xs-6 ">
                            <label>钉铛分成</label>
                            <input name="commission" type="text" class="form-control" value="<?php echo $error['commission']?>" check-type="required">
                        </div>
                        <div class="form-group col-xs-6 ">
                            <label>渠道费</label>
                            <input name="channel_fee" type="text" class="form-control" value="<?php echo $error['channel_fee']?>" check-type="required">
                        </div>
                        <div class="form-group col-xs-6 ">
                            <label>优惠金额</label>
                            <input name="discount_price" type="text" class="form-control" value="<?php echo $error['discount_price']?>" check-type="required">
                        </div>
                        
                        <div class="form-group" style="margin-top: 24px;margin-left: 14px;float: left"><button id="btnSubmit" class="btn btn-info" type="button">提交</button></div>
                        
					</form>
					
            	</div><!-- /.table-responsive -->
			</div>
			
		</div><!-- /.row -->
	</div><!-- /.page-content -->
	<script type="text/javascript">
        $('#btnSubmit').click(function(){
        	var order_id = "<?php echo $order['id']?>";
        	var date = "<?php echo $order['create_time']?>";
            var real_price = $('input[name="real_price"]').val();
            var order_price = $('input[name="order_price"]').val();
            var commission = $('input[name="commission"]').val();
            var channel_fee = $('input[name="channel_fee"]').val();
            var discount_price = $('input[name="discount_price"]').val();
            if(real_price == '请选择'){
                alert('原始金额不能为空');
                return;
            }
            if(order_price == ''){
                alert('订单金额不能为空');
                return;
            }
            if(commission == ''){
                alert('钉铛分成不能为空');
                return;
            }
            if(channel_fee == ''){
                alert('渠道费不能为空');
                return;
            }
            if(discount_price == ''){
                alert('优惠金额不能为空');
                return;
            }
            if(parseFloat(real_price) != order_price + discount_price){
            	alert('金额有误：总金额应该=订单金额+优惠金额');
            	return;
            }
            $('#btnSubmit').text('请稍后...');

            $.post('<?php echo base_url()."/admin/systems/make_edit_order"?>',{
            	order_id:order_id,
            	date:date,
                real_price:real_price,
                order_price:order_price,
                commission:commission,
                channel_fee:channel_fee,
                discount_price:discount_price,
            },function(res){
                $('#btnSubmit').text('提交');
                var data = JSON.parse(res);
                if(data.status == 1){
                    alert('修改成功!');
                }else{
                    alert('修改失败：'+data.msg);
                }
                
            })
        })
	</script>
</div><!-- /.main-content -->
